#include <buola/gui.h>

#include <buola/gui/cpropertytype.h>

namespace buola { namespace gui {

static std::unordered_map<std::wstring,CPropertyType*> &property_types()
{
    static std::unordered_map<std::wstring,CPropertyType*> lTypes;
    return lTypes;
}

CPropertyType::CPropertyType(const std::wstring &pName)
        : mName(pName)
{
}

CPropertyType *CPropertyType::GetType(const std::wstring &pName)
{
    CPropertyType *lType=property_types()[pName];
    
    if(!lType) throw XNotFound("can't find property type "+utf8(pName));

    return lType;
}

void CPropertyType::RegisterType(const std::wstring &pName,CPropertyType *pType)
{
    property_types()[pName]=pType;
}

/*namespace gui*/ } /*namespace buola*/ }
